// pages/index/doctor/doctor.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    qyshow: !0,
    provinceListIndex: 0, //省下得市
    local: '选择地区',
    department: '选择科室',
    Title: '选择职称',
    screen: '筛选',
    regionName: "区域",
    sectionName: "科室",
    hospitalName: "医院名称",
    i: 0,
    // 医院
    hospitalList: [{
      name: '山西大医院'
    },
    {
      name: '武警医院'
    },
    {
      name: '山大医院'
    },
    {
      name: '煤炭医院'
    },
    {
      name: '儿童医院'
    },
    {
      name: '儿童医院'
    },
    {
      name: '儿童医院'
    }
    ],
    input: '',
    arr: [
    ],
    departments: ['内科', '外科', '儿科', '妇科', '眼科', '耳鼻喉科', '口腔科', '皮肤科', '中医科', '针灸推拿科', '呼吸内科', '消化内科', '泌尿内科', '心内科', '血液科', '内分泌科', '神经内科', '小儿科', '感染科', '普外科', '骨科', '神经外科', '肝胆外科', '泌尿外科', '烧伤科', '妇科', '产科'],
    Titles: ['主治医师', '主任医师', '副主任医师', '住院医师'],
    screens: ['4-5', '3-4', '2-3', '1-2']
  },
  select: function (t) {
    var that = this;
    let id = t.currentTarget.dataset.id;
    // let isShow = that.data.isShow;
    //查询所有区域
    if (t.currentTarget.dataset.id == 1) {
      let qyshow = that.data.qyshow;
      let pxshow = that.data.pxshow;
      let nzshow = that.data.nzshow;
      app.util.request({
        'url': 'entry/wxapp/address',
        data: {
          op: 'quyu'
        },
        success: function (res) {
          console.log(res)
          var quyu = res.data;
          that.setData({
            provinceList: res.data,
            selectIndex: 1,
            qyshow: !that.data.qyshow,
            pxshow: !0,
            nzshow: !0
          })
        },
        fail: function (err) {
          console.log(err)
        },
      })
    }
    if (t.currentTarget.dataset.id == 2) {
      let qyshow = that.data.qyshow;
      let pxshow = that.data.pxshow;
      let nzshow = that.data.nzshow;
      that.setData({
        selectIndex: 2,
        pxshow: !pxshow,
        qyshow: !0,
        nzshow: !0
      })
    }
    if (t.currentTarget.dataset.id == 3) {
      let qyshow = that.data.qyshow;
      let pxshow = that.data.pxshow;
      let nzshow = that.data.nzshow;
      that.setData({
        // provinceList: res.data,
        selectIndex: 3,
        nzshow: !that.data.nzshow,
        pxshow: !0,
        qyshow: !0
      })
    }
  },
  selectPartsAll: function (t) {
    console.log(t);
    var e = this;
    o.default.selectPartsAll(t, e);
  },
  //看到选中省下得市
  selectParts: function (t) {
    var e = this;
    // console.log(t), o.default.selectParts(t, e);
    console.log(t)
    e.setData({
      provinceIndex: t.target.dataset.index,
      provinceListIndex: t.target.dataset.index
    })
  },
  selectHosptalAll: function (t) {
    var e = this;
    o.default.selectHosptalAll(t, e);
  },
  //选哪个医院
  selectHosptal: function (e) {
    let hospital = e.currentTarget.dataset.hospital;
    this.setData({
      hospitalName: hospital,
      pxshow: !0,
      // selectIndex:3
    })
  },
  //确定那个城市
  selectCity: function (e) {
    var that = this;
    // o.default.selectCity(t, e);
    let city = e.currentTarget.dataset.city;
    let id = e.currentTarget.dataset.id;
    let selectIndex = that.data.selectIndex;
    //查询医院
    if (selectIndex == 1) {
      app.util.request({
        'url': 'entry/wxapp/address',
        data: {
          op: 'yiyuan',
          par_id: id
        },
        success: function (res) {
          console.log(id)
          console.log(res)
          that.setData({
            hospitalList: res.data,
            qyshow: !0,
            // selectIndex: 2,
            // pxshow: !1
            // hospitalName: res.data[0].hos_name
          })
        },
        fail: function (err) {
          console.log(err)
        },
      })
    }
    this.setData({
      qyshow: !0,
      selectIndex: 0,
      regionName: city,
    })
  },
  option: function (e) {
    let that = this;
    console.log(e)
    let a = e.currentTarget.dataset.id;
    that.setData({
      i: a
    })
  },
  input: function (t) {
    console.log(t.detail.value), this.setData({
      input: t.detail.value
    });
  },
  grabble: function () {
    var a = this;
    let b = a.data.input;
    if (b == '') {
      wx.showToast({
        title: "请输入医生名字",
        icon: "none",
        duration: 1e3
      });
    } else {
      var o = wx.getStorageSync("log") || "";
      wx.request({
        url: t.globalData.dic + "doctor/manage/searchMyPatient",
        data: {
          token: o,
          keyWord: wx.getStorageSync("input") || ""
        },
        method: "POST",
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        success: function (t) {
          console.log(t.data.data), 0 == t.data.data.length ? wx.showToast({
            title: "查无此人",
            icon: "none",
            duration: 2e3
          }) : a.setData({
            arr: t.data.data
          });
        }
      });
    }
  },
  bindRegionChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      local: e.detail.value[2]
    })
  },
  bindRegionChange2: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    let that = this;
    let a = e.detail.value;
    let b = that.data.departments[a];
    that.setData({
      department: b
    })
  },
  bindRegionChange3: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    let that = this;
    let a = e.detail.value;
    let b = that.data.Titles[a];
    this.setData({
      Title: b
    })
  },
  bindRegionChange4: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    let that = this;
    let a = e.detail.value;
    let b = that.data.screens[a];
    this.setData({
      screen: b
    })
  },
  choice: function () {

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let a = this.data.arr;
    for (let i = 0; i < a.length; i++) {
      if (a[i].good.length > 20) {
        a[i].good = a[i].good.substr(0, 20) + '...'
      }
    }
    this.getAllzhuanjia()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  getAllzhuanjia: function () {
    var that = this
    app.util.request({
      'url': 'entry/wxapp/Zhuanjia',
      success: function (res) {
        console.log(res)
        var info = res.data.data
        that.setData({
          zhuanjia: info
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },
})